package com.elysia.blogspringboot.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.elysia.blogspringboot.properties.AliyunOssProperties;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RequiredArgsConstructor
@Slf4j
public class AliyunOssConfiguration{
    @Bean
    public OSS ossClient(AliyunOssProperties aliyunOssProperties) {
        String httpsEndpoint = "https://" + aliyunOssProperties.getEndpoint();
        return new OSSClientBuilder().build(
                httpsEndpoint,
                aliyunOssProperties.getAccessKeyId(),
                aliyunOssProperties.getAccessKeySecret());
    }
}
